
#include <iostream>
#include <QPushButton>
#include <QHBoxLayout>
#include <QFrame>
#include <QFile>
#include "turbomenu.h"

TurboMenu::TurboMenu(QWidget *parent)
    : QWidget(parent)
{
    setWindowFlags( Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
    initUi();
}

TurboMenu::~TurboMenu()
{

}

void TurboMenu::initUi()
{
    QFrame *frame = new QFrame(this);
    QHBoxLayout *layout1 = new QHBoxLayout(this);
    QHBoxLayout *layout2 = new QHBoxLayout(this);
    frame->setLayout(layout1);
    setLayout(layout2);
    QPushButton *btnRect = new QPushButton(this);
    btnRect->setIcon(QIcon(":resources/image/rectangle.png"));
    btnRect->setIconSize(QSize(16, 16));
    connect(btnRect, &QPushButton::clicked, this, &TurboMenu::btnRectClicked);
    QPushButton *btnEllipse = new QPushButton(this);
    btnEllipse->setIcon(QIcon(":resources/image/ellipse.png"));
    btnEllipse->setIconSize(QSize(16, 16));
    connect(btnEllipse, &QPushButton::clicked, this, &TurboMenu::btnEllipseClicked);
    QPushButton *btnArrow = new QPushButton(this);
    btnArrow->setIcon(QIcon(":resources/image/arrow.png"));
    btnArrow->setIconSize(QSize(16, 16));
    connect(btnArrow, &QPushButton::clicked, this, &TurboMenu::btnArrowClicked);
    QPushButton *btnPaintbrush = new QPushButton(this);
    btnPaintbrush->setIcon(QIcon(":resources/image/paintbrush.png"));
    btnPaintbrush->setIconSize(QSize(16, 16));
    connect(btnPaintbrush, &QPushButton::clicked, this, &TurboMenu::btnPaintbrushClicked);
    QPushButton *btnMosaic = new QPushButton(this);
    btnMosaic->setIcon(QIcon(":resources/image/mosaic.png"));
    btnMosaic->setIconSize(QSize(16, 16));
    connect(btnMosaic, &QPushButton::clicked, this, &TurboMenu::btnMosaicClicked);
    QPushButton *btnSave = new QPushButton(this);
    btnSave->setIcon(QIcon(":resources/image/save.png"));
    btnSave->setIconSize(QSize(16, 16));
    connect(btnSave, &QPushButton::clicked, this, &TurboMenu::btnSaveClicked);
    QPushButton *btnQuit = new QPushButton(this);
    btnQuit->setIcon(QIcon(":resources/image/close.png"));
    btnQuit->setIconSize(QSize(16, 16));
    connect(btnQuit, &QPushButton::clicked, this, &TurboMenu::btnQuitClicked);
    layout1->addWidget(btnRect);
    layout1->addWidget(btnEllipse);
    layout1->addWidget(btnArrow);
    layout1->addWidget(btnPaintbrush);
    layout1->addWidget(btnMosaic);
    layout1->addWidget(btnSave);
    layout1->addWidget(btnQuit);
    layout2->addWidget(frame);
    QFile file(":resources/style/menu.qss");
    file.open(QIODevice::ReadOnly);
    QByteArray array = file.readAll();
    file.close();
    setStyleSheet(array);
}

void TurboMenu::btnRectClicked()
{
    emit sig_btnRectClicked();
}

void TurboMenu::btnEllipseClicked()
{
    emit sig_btnEllipseClicked();
}

void TurboMenu::btnArrowClicked()
{
    emit sig_btnArrowClicked();
}

void TurboMenu::btnPaintbrushClicked()
{
    emit sig_btnPaintbrushClicked();
}

void TurboMenu::btnMosaicClicked()
{
    emit sig_btnMosaicClicked();
}

void TurboMenu::btnSaveClicked()
{
    emit sig_btnSaveClicked();
}

void TurboMenu::btnQuitClicked()
{
    emit sig_btnQuitClicked();
}
